package edu.nf.project.webs.storeOperation;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import edu.nf.project.entitys.entity.storeOperation.convention.inspect.InspectImage;
import edu.nf.project.services.response.BaseController;
import edu.nf.project.services.response.ResultVO;
import edu.nf.project.services.storeOperation.InspectImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @author CSY
 * @date 2025 - 06 - 15
 */
@RestController
@RequestMapping("/api/inspect-image")
public class InspectImageController extends BaseController {
    @Autowired
    private InspectImageService inspectImageService;

    @GetMapping("/image/{siId}")
    public ResultVO<List<InspectImage>> listInspectImageBySiId(@PathVariable Integer siId) {
        List<InspectImage> inspectImages = inspectImageService.listInspectImageBySiId(siId);
        return success(inspectImages);
    }

    @PostMapping("/submit")
    public ResultVO<String> insertInspectImage(@RequestParam("files") MultipartFile [] files,
                                               @RequestParam("inspectImage") String inspectImageJson) {
        inspectImageService.insertInspectImage(files,inspectImageJson);
        return success();
    }
}
